package com.cenwangkeji.resident.ui.activity;

import android.os.Bundle;
import android.widget.TextView;

import com.cenwangkeji.resident.R;
import com.cenwangkeji.resident.model.Constant;
import com.cenwangkeji.resident.model.bean.BasicInfoBean;
import com.cenwangkeji.resident.model.bean.User;
import com.cenwangkeji.resident.presenter.activity.BasicInfoPresenter;
import com.cenwangkeji.resident.utils.LoginUtils;
import com.lws.basic.base.BaseActivity;
import com.lws.basic.utils.common.MyToast;

import butterknife.BindView;
import butterknife.ButterKnife;

//基本档案
public class BasicInfoActivity extends BaseActivity implements BasicInfoPresenter.I{


    @BindView(R.id.tv_name)
    TextView mTvName;
    @BindView(R.id.tv_sex)
    TextView mTvSex;
    @BindView(R.id.tv_birth)
    TextView mTvBirth;
    @BindView(R.id.tv_work)
    TextView mTvWork;
    @BindView(R.id.tv_phone)
    TextView mTvPhone;
    @BindView(R.id.tv_type)
    TextView mTvType;
    @BindView(R.id.tv_nation)
    TextView mTvNation;
    private BasicInfoPresenter mPresenter = new BasicInfoPresenter(this);

    @Override
    public int setLayoutId() {
        return R.layout.activity_basic_info;
    }

    @Override
    public void initData() {
        super.initData();
        ButterKnife.bind(this);
        showLoading();
        mPresenter.getUserDetail();
    }


    @Override//获取用户信息成功
    public void onUserInfoSuccess(BasicInfoBean bean) {
        if (bean.getMsg().equals(Constant.token_expired)){
           signIn();
        }else {
            if (bean.getData() != null){
                mTvName.setText(bean.getData().getXm());
                if (bean.getData().getXb()==1){
                    mTvSex.setText("男");
                }else {
                    mTvSex.setText("女");
                }
                mTvBirth.setText(bean.getData().getCsrq());
                mTvWork.setText(bean.getData().getGzdw());
                mTvPhone.setText(bean.getData().getPhone());
                if (bean.getData().getCzlx() ==1){
                    mTvType.setText("户籍");
                }else {
                    mTvType.setText("非户籍");
                }
                mTvNation.setText(User.getNation(bean.getData().getMz()));
            }else {
                MyToast.show(bean.getMsg());
            }
        }
        dismissLoading();
    }
}
